-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Uptime] Add functional UI tests #29667
[Uptime] Add functional UI tests #29667
Conversation
* Add API functional tests for uptime graphQL. * Remove obsolete code. * Add CI group for UI functional tests. * Delete obsolete code, rename heartbeat es archive. * Refactor adapter methods. * Refactor adapter methods. * Attempt to fix ci-group tag error. * Skip functional app tests until later PR. * Remove unused code. * Optimize test runs. * Add uptime to api test index. * Fix formatting.
…ch_monitors_adapter.ts Implement PR feedback. Co-Authored-By: justinkambic <[email protected]>
💚 Build Succeeded |
My first run of this locally failed for me. It looks like it didn't get the time set correctly. I'll run again and see if I can see why;
|
I temporarily hacked this method in test\functional\page_objects\time_picker.js to check if the superDatePickerShowDatesButton exists immediately or not; async showStartEndTimes() {
let isShowDatesButton = await testSubjects.exists('superDatePickerShowDatesButton');
console.log(`+++++++++++++ time_picker.js isShowDatesButton = ${isShowDatesButton}` );
isShowDatesButton = await testSubjects.exists('superDatePickerShowDatesButton');
console.log(`+++++++++++++ time_picker.js isShowDatesButton = ${isShowDatesButton}` );
isShowDatesButton = await testSubjects.exists('superDatePickerShowDatesButton');
console.log(`+++++++++++++ time_picker.js isShowDatesButton = ${isShowDatesButton}` );
isShowDatesButton = await testSubjects.exists('superDatePickerShowDatesButton');
console.log(`+++++++++++++ time_picker.js isShowDatesButton = ${isShowDatesButton}` );
isShowDatesButton = await testSubjects.exists('superDatePickerShowDatesButton');
console.log(`+++++++++++++ time_picker.js isShowDatesButton = ${isShowDatesButton}` );
isShowDatesButton = await testSubjects.exists('superDatePickerShowDatesButton');
console.log(`+++++++++++++ time_picker.js isShowDatesButton = ${isShowDatesButton}` );
isShowDatesButton = await testSubjects.exists('superDatePickerShowDatesButton');
console.log(`+++++++++++++ time_picker.js isShowDatesButton = ${isShowDatesButton}` );
if (isShowDatesButton) {
await testSubjects.click('superDatePickerShowDatesButton');
}
} And in the output I see that it initially returns false (page is still loading) but then returns true after a couple of seconds, and then the date does get set properly;
But then I'm ending up with a blank page; |
jenkins test this |
💚 Build Succeeded |
I have it passing locally for me now with 2 changes; The first change is in The second change in Ideally we wouldn't navigate first to home, and then to uptime. But navigating directly to uptime doesn't work for some reason.
|
Here's my changes now with navigating directly to uptime app and with timestamps removed from URLs $ git diff
diff --git a/test/functional/page_objects/time_picker.js b/test/functional/page_objects/time_picker.js
index 99f4e8b3b6..679c73dbbf 100644
--- a/test/functional/page_objects/time_picker.js
+++ b/test/functional/page_objects/time_picker.js
@@ -122,6 +122,8 @@ export function TimePickerPageProvider({ getService, getPageObjects }) {
}
async showStartEndTimes() {
+ // This first await makes sure the superDatePicker has loaded before we check for the ShowDatesButton
+ await testSubjects.exists('superDatePickerToggleQuickMenuButton', { timeout: 20000 });
const isShowDatesButton = await testSubjects.exists('superDatePickerShowDatesButton');
if (isShowDatesButton) {
await testSubjects.click('superDatePickerShowDatesButton');
diff --git a/test/functional/services/browser.js b/test/functional/services/browser.js
index cac147f2f0..57a29b6d83 100644
--- a/test/functional/services/browser.js
+++ b/test/functional/services/browser.js
@@ -77,7 +77,7 @@ export async function BrowserProvider({ getService }) {
* @param {boolean} insertTimestamp Optional
* @return {Promise<void>}
*/
- async get(url, insertTimestamp = true) {
+ async get(url, insertTimestamp = false) {
if (insertTimestamp) {
const urlWithTime = modifyUrl(url, parsed => {
parsed.query._t = Date.now();
diff --git a/x-pack/test/functional/page_objects/uptime_page.ts b/x-pack/test/functional/page_objects/uptime_page.ts
index 7ceae44be0..a2ecead444 100644
--- a/x-pack/test/functional/page_objects/uptime_page.ts
+++ b/x-pack/test/functional/page_objects/uptime_page.ts
@@ -18,8 +18,7 @@ export const UptimePageProvider = ({
datePickerStartValue: string,
monitorIdToCheck: string
) {
- await pageObject.common.navigateToApp('home');
- await uptimeService.navigateToPlugin();
+ await pageObject.common.navigateToApp('uptime');
await pageObject.timePicker.setAbsoluteStart(datePickerStartValue);
await uptimeService.monitorIdExists(monitorIdToCheck);
}
@@ -29,8 +28,7 @@ export const UptimePageProvider = ({
monitorId: string,
monitorName: string
) {
- await pageObject.common.navigateToApp('home');
- await uptimeService.navigateToPlugin();
+ await pageObject.common.navigateToApp('uptime');
await pageObject.timePicker.setAbsoluteStart(datePickerStartValue);
await uptimeService.navigateToMonitorWithId(monitorId);
if ((await uptimeService.getMonitorNameDisplayedOnPageTitle()) !== monitorName) {
diff --git a/x-pack/test/functional/services/uptime.ts b/x-pack/test/functional/services/uptime.ts
index ed08be75c8..ea4fd9f6ac 100644
--- a/x-pack/test/functional/services/uptime.ts
+++ b/x-pack/test/functional/services/uptime.ts
@@ -16,6 +16,7 @@ export const UptimeProvider = ({ getService }: KibanaFunctionalTestDefaultProvid
},
async navigateToPlugin() {
await testSubjects.click('homeSynopsisLinkuptime');
+ await testSubjects.find('kibanaChrome', 240000);
},
async monitorIdExists(key: string) {
await testSubjects.existOrFail(key);
|
💔 Build Failed |
@LeeDr I'm guessing that by defaulting the inclusion of timestamp |
…ected router path is not satisfied.
@LeeDr let me know what you think of 9c886e8. I have added some code that will manually change the I've included a comment explaining why that code is there, and am open to alternative solutions. Given that this code will only really be invoked when running these tests, and real-life navigation in Kibana or via sharing URLs shouldn't impact the plugin, I think this is an acceptable temporary fix. |
💔 Build Failed |
💚 Build Succeeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
return { | ||
async assertExists(key: string) { | ||
if (!(await testSubjects.exists(key))) { | ||
throw new Error(`Couldn't find expected element with key "${key}".`); | ||
} | ||
}, | ||
async navigateToPlugin() { | ||
await testSubjects.click('homeSynopsisLinkuptime'); | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a problem here. This method is clicking the homeSynopsisLinkuptime
link but not waiting for the page to load. I still see the spinning K while the test is trying to set the from time.
You might want to consider changing the uptime_page.ts goToUptimeOverviewAndLoadData method like this (take out navigating to home and then to the plugin and navigateToApp straight to uptime since that navigateToApp already should have the appropriate wait for the page to load build in
// await pageObject.common.navigateToApp('home');
// await uptimeService.navigateToPlugin();
await pageObject.common.navigateToApp('uptime');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK we aren't using that code anymore, so we can probably delete it safely altogether. I'll post back here after I investigate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LeeDr it looks like we actually did delete that code already, so I think we're good!
* Refactor es queries and associated components/endpoints. * Add unit tests, repair broken tests. * [Uptime] Add API functional tests for uptime graphQL (elastic#29128) * Add API functional tests for uptime graphQL. * Remove obsolete code. * Add CI group for UI functional tests. * Delete obsolete code, rename heartbeat es archive. * Refactor adapter methods. * Refactor adapter methods. * Attempt to fix ci-group tag error. * Skip functional app tests until later PR. * Remove unused code. * Optimize test runs. * Add uptime to api test index. * Fix formatting. * Add HB 7.0 data for API tests. * Configure first error_list test to work with 7.x data. * Configure error_list filtered by id to work with 7.x data. * Configure error_list functional tests to work with 7.x data. * Update snapshot test to work with 7.x data. * Update snapshot down filtered test to work with 7.x data. * Configure snapshot up test to work with 7.x data. * Configure ping list tests to work with 7.x data. * Configure monitor list tests to work with 7.x data. * Configure monitor status bar tests to work with 7.x data. * Configure filterBar tests to work with 7.x data. * Configure docCount tests to work with 7.x data. * Simplify code based on PR feedback. * Add loading spinner to monitor page title based on PR feedback. * Rename GQL type based on PR feedback. * Remove use of 'undefined' in ES query based on PR feedback. * Simplify code based on PR feedback. * Add definite size/shard_size for terms agg based on PR feedback. * Simplify ES query based on PR feedback. * Update x-pack/plugins/uptime/server/lib/adapters/monitors/elasticsearch_monitors_adapter.ts Implement PR feedback. Co-Authored-By: justinkambic <[email protected]> * Increase size for ES errors query based on PR feedback. * Fix hardcoded field in terms filter based on PR feedback. * Simplify get code for monitors function. * Reduce unnecessarily large size for terms agg based on PR feedback. * Pluralize filter bar props. * Refactor filter bar query based on PR feedback. * Update test. * Fix busted GQL query. * Update functional test docs to use data without buggy values. * Update index name in HB functional api test docs. * Update snapshot base functional test. * Make snapshot filter tests pass, fix associated bug. * Configure remaining snapshot e2e tests to work with 7.x data. * Give better variable names and comments for ugly code. * Configure ping list query tests to work with updated 7.x data. * Rename graphql describe block. * Update monitor status bar query tests to work with updated 7.x data. * Update monitor list query tests to work with updated 7.x data. * Update filter bar query to work with updated 7.x data. * Update error list query to work with updated 7.x data. * Update doc count fixture to work with new 7.x data. * Create functional UI tests for Overview and Monitor pages. * Add additional waits to functional UI test to try to prevent flakiness. * [ftr/services/superDatePicker] make specialized service * Add data-test-subj value to monitor link. * Remove wait calls from UI tests. * Set default timezone for tests' kibana server. * Add @types for mocha and expect.js. * Implement PR feedback. * Remove added types. * Re-add mocha types. * Remove obsolete comment. * Disable timestamp on uptime app navigation for functional tests. * Undo previous change for default value of function parameter. * Add redirect hack to uptime client to change window location when expected router path is not satisfied.
* Refactor es queries and associated components/endpoints. * Add unit tests, repair broken tests. * [Uptime] Add API functional tests for uptime graphQL (elastic#29128) * Add API functional tests for uptime graphQL. * Remove obsolete code. * Add CI group for UI functional tests. * Delete obsolete code, rename heartbeat es archive. * Refactor adapter methods. * Refactor adapter methods. * Attempt to fix ci-group tag error. * Skip functional app tests until later PR. * Remove unused code. * Optimize test runs. * Add uptime to api test index. * Fix formatting. * Add HB 7.0 data for API tests. * Configure first error_list test to work with 7.x data. * Configure error_list filtered by id to work with 7.x data. * Configure error_list functional tests to work with 7.x data. * Update snapshot test to work with 7.x data. * Update snapshot down filtered test to work with 7.x data. * Configure snapshot up test to work with 7.x data. * Configure ping list tests to work with 7.x data. * Configure monitor list tests to work with 7.x data. * Configure monitor status bar tests to work with 7.x data. * Configure filterBar tests to work with 7.x data. * Configure docCount tests to work with 7.x data. * Simplify code based on PR feedback. * Add loading spinner to monitor page title based on PR feedback. * Rename GQL type based on PR feedback. * Remove use of 'undefined' in ES query based on PR feedback. * Simplify code based on PR feedback. * Add definite size/shard_size for terms agg based on PR feedback. * Simplify ES query based on PR feedback. * Update x-pack/plugins/uptime/server/lib/adapters/monitors/elasticsearch_monitors_adapter.ts Implement PR feedback. Co-Authored-By: justinkambic <[email protected]> * Increase size for ES errors query based on PR feedback. * Fix hardcoded field in terms filter based on PR feedback. * Simplify get code for monitors function. * Reduce unnecessarily large size for terms agg based on PR feedback. * Pluralize filter bar props. * Refactor filter bar query based on PR feedback. * Update test. * Fix busted GQL query. * Update functional test docs to use data without buggy values. * Update index name in HB functional api test docs. * Update snapshot base functional test. * Make snapshot filter tests pass, fix associated bug. * Configure remaining snapshot e2e tests to work with 7.x data. * Give better variable names and comments for ugly code. * Configure ping list query tests to work with updated 7.x data. * Rename graphql describe block. * Update monitor status bar query tests to work with updated 7.x data. * Update monitor list query tests to work with updated 7.x data. * Update filter bar query to work with updated 7.x data. * Update error list query to work with updated 7.x data. * Update doc count fixture to work with new 7.x data. * Create functional UI tests for Overview and Monitor pages. * Add additional waits to functional UI test to try to prevent flakiness. * [ftr/services/superDatePicker] make specialized service * Add data-test-subj value to monitor link. * Remove wait calls from UI tests. * Set default timezone for tests' kibana server. * Add @types for mocha and expect.js. * Implement PR feedback. * Remove added types. * Re-add mocha types. * Remove obsolete comment. * Disable timestamp on uptime app navigation for functional tests. * Undo previous change for default value of function parameter. * Add redirect hack to uptime client to change window location when expected router path is not satisfied.
* Refactor es queries and associated components/endpoints. * Add unit tests, repair broken tests. * [Uptime] Add API functional tests for uptime graphQL (#29128) * Add API functional tests for uptime graphQL. * Remove obsolete code. * Add CI group for UI functional tests. * Delete obsolete code, rename heartbeat es archive. * Refactor adapter methods. * Refactor adapter methods. * Attempt to fix ci-group tag error. * Skip functional app tests until later PR. * Remove unused code. * Optimize test runs. * Add uptime to api test index. * Fix formatting. * Add HB 7.0 data for API tests. * Configure first error_list test to work with 7.x data. * Configure error_list filtered by id to work with 7.x data. * Configure error_list functional tests to work with 7.x data. * Update snapshot test to work with 7.x data. * Update snapshot down filtered test to work with 7.x data. * Configure snapshot up test to work with 7.x data. * Configure ping list tests to work with 7.x data. * Configure monitor list tests to work with 7.x data. * Configure monitor status bar tests to work with 7.x data. * Configure filterBar tests to work with 7.x data. * Configure docCount tests to work with 7.x data. * Simplify code based on PR feedback. * Add loading spinner to monitor page title based on PR feedback. * Rename GQL type based on PR feedback. * Remove use of 'undefined' in ES query based on PR feedback. * Simplify code based on PR feedback. * Add definite size/shard_size for terms agg based on PR feedback. * Simplify ES query based on PR feedback. * Update x-pack/plugins/uptime/server/lib/adapters/monitors/elasticsearch_monitors_adapter.ts Implement PR feedback. Co-Authored-By: justinkambic <[email protected]> * Increase size for ES errors query based on PR feedback. * Fix hardcoded field in terms filter based on PR feedback. * Simplify get code for monitors function. * Reduce unnecessarily large size for terms agg based on PR feedback. * Pluralize filter bar props. * Refactor filter bar query based on PR feedback. * Update test. * Fix busted GQL query. * Update functional test docs to use data without buggy values. * Update index name in HB functional api test docs. * Update snapshot base functional test. * Make snapshot filter tests pass, fix associated bug. * Configure remaining snapshot e2e tests to work with 7.x data. * Give better variable names and comments for ugly code. * Configure ping list query tests to work with updated 7.x data. * Rename graphql describe block. * Update monitor status bar query tests to work with updated 7.x data. * Update monitor list query tests to work with updated 7.x data. * Update filter bar query to work with updated 7.x data. * Update error list query to work with updated 7.x data. * Update doc count fixture to work with new 7.x data. * Create functional UI tests for Overview and Monitor pages. * Add additional waits to functional UI test to try to prevent flakiness. * [ftr/services/superDatePicker] make specialized service * Add data-test-subj value to monitor link. * Remove wait calls from UI tests. * Set default timezone for tests' kibana server. * Add @types for mocha and expect.js. * Implement PR feedback. * Remove added types. * Re-add mocha types. * Remove obsolete comment. * Disable timestamp on uptime app navigation for functional tests. * Undo previous change for default value of function parameter. * Add redirect hack to uptime client to change window location when expected router path is not satisfied.
* Refactor es queries and associated components/endpoints. * Add unit tests, repair broken tests. * [Uptime] Add API functional tests for uptime graphQL (#29128) * Add API functional tests for uptime graphQL. * Remove obsolete code. * Add CI group for UI functional tests. * Delete obsolete code, rename heartbeat es archive. * Refactor adapter methods. * Refactor adapter methods. * Attempt to fix ci-group tag error. * Skip functional app tests until later PR. * Remove unused code. * Optimize test runs. * Add uptime to api test index. * Fix formatting. * Add HB 7.0 data for API tests. * Configure first error_list test to work with 7.x data. * Configure error_list filtered by id to work with 7.x data. * Configure error_list functional tests to work with 7.x data. * Update snapshot test to work with 7.x data. * Update snapshot down filtered test to work with 7.x data. * Configure snapshot up test to work with 7.x data. * Configure ping list tests to work with 7.x data. * Configure monitor list tests to work with 7.x data. * Configure monitor status bar tests to work with 7.x data. * Configure filterBar tests to work with 7.x data. * Configure docCount tests to work with 7.x data. * Simplify code based on PR feedback. * Add loading spinner to monitor page title based on PR feedback. * Rename GQL type based on PR feedback. * Remove use of 'undefined' in ES query based on PR feedback. * Simplify code based on PR feedback. * Add definite size/shard_size for terms agg based on PR feedback. * Simplify ES query based on PR feedback. * Update x-pack/plugins/uptime/server/lib/adapters/monitors/elasticsearch_monitors_adapter.ts Implement PR feedback. Co-Authored-By: justinkambic <[email protected]> * Increase size for ES errors query based on PR feedback. * Fix hardcoded field in terms filter based on PR feedback. * Simplify get code for monitors function. * Reduce unnecessarily large size for terms agg based on PR feedback. * Pluralize filter bar props. * Refactor filter bar query based on PR feedback. * Update test. * Fix busted GQL query. * Update functional test docs to use data without buggy values. * Update index name in HB functional api test docs. * Update snapshot base functional test. * Make snapshot filter tests pass, fix associated bug. * Configure remaining snapshot e2e tests to work with 7.x data. * Give better variable names and comments for ugly code. * Configure ping list query tests to work with updated 7.x data. * Rename graphql describe block. * Update monitor status bar query tests to work with updated 7.x data. * Update monitor list query tests to work with updated 7.x data. * Update filter bar query to work with updated 7.x data. * Update error list query to work with updated 7.x data. * Update doc count fixture to work with new 7.x data. * Create functional UI tests for Overview and Monitor pages. * Add additional waits to functional UI test to try to prevent flakiness. * [ftr/services/superDatePicker] make specialized service * Add data-test-subj value to monitor link. * Remove wait calls from UI tests. * Set default timezone for tests' kibana server. * Add @types for mocha and expect.js. * Implement PR feedback. * Remove added types. * Re-add mocha types. * Remove obsolete comment. * Disable timestamp on uptime app navigation for functional tests. * Undo previous change for default value of function parameter. * Add redirect hack to uptime client to change window location when expected router path is not satisfied.
Summary
This PR adds some functional UI tests to ensure the pages load, and checks for a few basic values.
Testing this PR
You can refer to the plugin's README for instructions on running functional UI tests. If the instructions are unclear please open an issue for a README update.
NOTE: do not review until #29398 is merged